﻿<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl<MBS_FoodBooking.Models.FoodItem>" %>

<%--<% using (Ajax.BeginForm("AddtoCart", "FoodBooking", new AjaxOptions {  UpdateTargetId = "shoppingCart"}))
   { %>--%>
<table>
<tr>
<td colspan="2" align="center">
<img  src='<%= Url.Content(Model.ImgUrl)%>' style="width:110px; height:120px" />
</td>
</tr>
<tr>
<%--<td align="right">
 <%= Html.Label("Name ") %>
</td>--%>
<td align="left" style="font-family:@Dotum; ">
<%= Html.Label("lblName", Model.Name)%>
</td>
</tr>
<tr>
<%--<td align="right">
 <%= Html.Label("Price") %>
</td>--%>
<td align="left" style="font-family:@Dotum; ">
<%= Html.Label("lblPrice","$ "+ Model.ItemPrice.ToString("#,##0.00#"))%>
</td>
</tr>
<tr>
<%--<td align="right">
 <%= Html.Label("Quantity") %>
</td>--%>
<td align="left">
 <%= Html.TextBox("txtQuantity")%>
</td>
</tr>
<%--<tr>
<td>
<input  type="checkbox"  name="chkAdd"/>
 
</td>
</tr>
--%>
</table>
<%--<%} %>
--%>
<%-- <script type="text/javascript">
     var addtoCartUrl = '<%= Url.Action("AddtoCart", "FoodBooking") %>';
    </script>
    
    <script type="text/javascript">
        $(document).ready(function () {
            $('#btns').click(function () {
                alert('hi');
            });
            $('#chkAdd').change(function () {
                debugger;
                var thisCheck = $(this);
                if (thischeck.is(':checked')) {
                    var quantity = $(this).closest('table').find('#txtQuantity').val();
                    if (quantity == null || quantity == 0) {
                        alert('Please enter a valid quantity');
                        $(this).closest('table').find('#txtQuantity').focus();
                    }
                    else {
                        var item = new {

                            ItemName: $.trim($(this).closest('table').find('#lblName').text()),
                            Quantity: $.trim($(this).closest('table').find('#txtQuantity').val()),
                            ItemPrice: $.trim($(this).closest('table').find('#lblPrice').text())
                        };

                        $.ajax({
                            type: "POST",
                            url: addtoCartUrl,
                            data: data,
                            contentType: "application/json;charset=utf-8",
                            dataType: "json",
                            async: true,
                            cache: false,
                            success: function (msg) {
                                alert(msg);
                                alert(msg.d);
                            },
                            error: function (x, e) {
                                alert("The call to the server side failed. " + x.responseText);
                            }
                        });

                    }
                }
                else {

                }

            });
        });
    
    </script>
--%>